package Web;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import EmpDao.EmpDao;

public class DeleteEmpServlet extends HttpServlet {

	public void service(HttpServletRequest req, HttpServletResponse res)
			throws ServletException, IOException {
		
		//1、获取请求参数
		String id=req.getParameter("id");
		//2、将此员工删除
		EmpDao dao=new EmpDao();
		dao.delete(new Integer(id));
		//3、将页面跳转至员工列表页面，由于查询员工和删除员工彼此是独立的组件，彼此不 依赖，所以使用重定向实现本次跳转！
		res.sendRedirect("findEmp");

	/*	res.setContentType("text/html;charset=utf-8");
		PrintWriter out = res.getWriter();
*/
	}

}
